package com.qn.example.mapper;

import com.qn.example.pojo.Setmeal;
import com.qn.example.pojo.dto.SetmealDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;


/**
 * @author 21276
 */
public interface SetmealMapper {
    @Select("select count(*) from setmeal where category_id = #{id}")
    Integer findDishCountByCategoryId(Long id);

    @Insert("insert into setmeal value(null,#{categoryId},#{name},#{price},#{status},#{code}," +
            "#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    //返回插入当前数据后自增长生成的id
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void saveSetmeal(SetmealDto setmealDto);

    List<Setmeal> findByPage(String name);

    void deleteids(@Param("ids") List<Long> ids);

    void dishStatusByStatus(@Param("status") Integer status , @Param("ids") List<Long> ids,@Param("updateTime") LocalDateTime updateTime);

    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);

    @Select("select * from setmeal where category_id = #{categoryId} and status = #{status}")
    List<Setmeal> list(@Param("categoryId")Long categoryId,@Param("status")  Integer status);
}
